#include <bits/stdc++.h>
using namespace std;
#define int long long
void solve()
{
	int n;
	cin>>n;
	vector<int>v(n+1);
	for(int i=1;i<=n;i++)
	{
		cin>>v[i];
	}
	int ans=0;
	bool f=0;
	for(int i=0;i<=60;i++)
	{
		if(f)
		{
			ans+=1ll<<i;
			continue;
		}
		bool y=0;
		for(int j=1;j<=n;j++)
		{
			if(i==0)
			{
				f^=(v[j]&(1ll<<i));
			}
			else  
			{
				bool x=(v[j]&(1ll<<i));
				f^=x;
				bool z=(v[j]&(1ll<<(i-1)));
				if(x!=z)y=1;
			}
		}
		f=f||y;
		if(f)ans+=1ll<<i;
	}
	cout<<ans<<endl;
}
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int T=1;
	cin>>T;
	while(T--)
	{
		solve();
	}
	return 0;
}